package cn.evun.tms.generator.task;

import cn.evun.tms.generator.framework.AbstractApplicationTask;
import cn.evun.tms.generator.framework.context.ApplicationContext;
import cn.evun.tms.generator.handler.BaseHandler;
import cn.evun.tms.generator.handler.impl.DtoHandler;
import cn.evun.tms.generator.model.DtoInfo;

import java.util.List;

public class DtoTask extends AbstractApplicationTask {

	private static String VO_FTL = "template/Dto.ftl";
	private List<DtoInfo> dtoList;

	@SuppressWarnings("unchecked")
	@Override
	protected boolean doInternal(ApplicationContext context) throws Exception {
		logger.info("开始生成Dto");
		dtoList = (List<DtoInfo>) context.getAttribute("dtoList");

		BaseHandler<DtoInfo> handler = null;
		for (DtoInfo DtoInfo : dtoList) {
			handler = new DtoHandler(VO_FTL, DtoInfo);
			handler.execute(context);
		}
		logger.info("结束生成Dto");
		return false;
	}

	@Override
	protected void doAfter(ApplicationContext context) throws Exception {
		super.doAfter(context);
	}

}
